Public Class ClaseGolosinaVisual
    Public Event formClosed()

    Private WithEvents timerLoad1 As New Timer
    Private WithEvents timerLoad2 As New Timer
    Private WithEvents timerLoad3 As New Timer
    Private WithEvents timerClose1 As New Timer
    Private WithEvents timerClose2 As New Timer
    Private WithEvents timerClose3 As New Timer
    Private WithEvents form As Form
    Private ancho As Integer
    Private alto As Integer
    Public Overridable Sub FadeIn(ByRef form As Form)
        MyClass.form = form
        MyClass.form.Opacity = 0
        With timerLoad3
            .Interval = 1
            .Enabled = True
        End With
    End Sub
    Public Overridable Sub FadeIn(ByRef form As Form, ByVal ancho As Integer, ByVal alto As Integer)
        MyClass.FadeIn(form)
        MyClass.form.Width = ancho
        MyClass.form.Height = alto
    End Sub

    Public Sub FadeOut(ByRef form As Form)
        MyClass.form = form
        With timerClose3
            .Interval = 1
            .Enabled = True
        End With
    End Sub

    Public Sub VentanaWow(ByRef form As Form, ByVal ancho As Integer, ByVal alto As Integer)
        With timerLoad1
            .Interval = 1
            .Enabled = True
        End With
        With timerLoad2
            .Interval = 1
            .Enabled = True
        End With
        With timerLoad3
            .Interval = 1
            .Enabled = True
        End With
        MyClass.alto = alto
        MyClass.ancho = ancho
        MyClass.form = form
        MyClass.form.Height = 1
        MyClass.form.Width = 1
        MyClass.form.Opacity = 0
        'cambiarancho()

    End Sub

    'Private Sub cambiarancho()
    '    For i As Integer = 0 To ancho
    '        form.Width = form.Width + 1
    '        For y As Integer = 0 To 500

    '            Application.DoEvents()
    '        Next
    '    Next
    'End Sub

    Public Sub VentanaWowClose()
        With timerClose1
            .Interval = 1
            .Enabled = True
        End With
        With timerClose2
            .Interval = 1
            .Enabled = True
        End With
        With timerClose3
            .Interval = 1
            .Enabled = True
        End With

    End Sub

    Private Sub CambiarAnchoFormClose(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerClose1.Tick


        form.Width = form.Width - CInt((ancho * 5) / 100)
        If form.Width <= 0 Then
            ' easy to change width
            timerClose1.Enabled = False
            form.Width = 0
        End If
        If (timerClose1.Enabled = False And _
            timerClose2.Enabled = False And _
            timerClose3.Enabled = False) Then

        End If

    End Sub
    Private Sub CambiarAltoFormClose(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerClose2.Tick
        form.Height = form.Height - CInt((ancho * 5) / 100)
        If form.Height <= 0 Then
            timerClose2.Enabled = False
            form.Height = 0
        End If
    End Sub

    Private Sub CambiarTransparenciaFormClose(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerClose3.Tick
        Try
            form.Opacity = form.Opacity - 0.05
            If (form.Opacity <= 0) Then
                timerClose3.Enabled = False
                form.Opacity = 0
                RaiseEvent formClosed()
            End If
        Catch ex As Exception
            timerLoad3.Enabled = False
        End Try

    End Sub

    Public Sub DatagridWow(ByRef DG As DataGridView, ByVal ancho As Integer, ByVal alto As Integer)

    End Sub

    Private Sub CambiarAnchoFormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerLoad1.Tick
        form.Width = form.Width + CInt((ancho * 5) / 100)
        If form.Width >= ancho Then
            ' easy to change width
            timerLoad1.Enabled = False
            form.Width = ancho
        End If

    End Sub
    Private Sub CambiarAltoFormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerLoad2.Tick
        form.Height = form.Height + CInt((ancho * 5) / 100)
        If form.Height >= alto Then
            timerLoad2.Enabled = False
            form.Height = alto
        End If
    End Sub

    Private Sub CambiarTransparenciaFormLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerLoad3.Tick
        Try
            form.Opacity = form.Opacity + 0.05
            If (form.Opacity >= CDbl(1.0)) Then
                timerLoad3.Enabled = False
                form.Opacity = 1
            End If
        Catch ex As Exception
            timerLoad3.Enabled = False
        End Try

    End Sub

End Class
